package lq;

import java.util.Scanner;
import java.util.regex.Pattern;

public class lq2043 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        in.nextLine();
        while (m--!=0){
            int count = 0;
            String mima =in.nextLine();
            if (mima.length()<8 || mima.length()>16){
                System.out.println("NO");
                continue;
            }
            if (Pattern.compile("[A-Z]").matcher(mima).find()){
                count++;
            }
            if (Pattern.compile("[a-z]").matcher(mima).find()){
                count++;
            }
            if (Pattern.compile("[0-9]").matcher(mima).find()){
                count++;
            }
            if (Pattern.compile("[~!@#$%^]").matcher(mima).find()){
                count++;
            }
            System.out.println(count>2? "YES":"NO");
        }
    }
}
